/**
    @file portal_debug.hpp
    @brief Debug rendering for PCZSceneManager
*/

#ifndef PM3_PORTAL_DEBUG_HPP
#define PM3_PORTAL_DEBUG_HPP

#include "logger.hpp"
#include "interface.hpp"
#include "bullet/BtOgreExtras.h"

namespace pm3 {
//! Pixelmaze debug features
namespace dbg {

    /**
        @class PORTAL_DRAWER
        @brief A singleton that draws portals for debugging purposes
    */
    class PORTAL_DRAWER: public Ogre::Singleton<PORTAL_DRAWER> {
    public:
        /**
            @brief A constructor
        */
	    PORTAL_DRAWER();
        /**
            @brief A destructor
        */
	    ~PORTAL_DRAWER();

        /**
            @brief Initializes the drawer
            @param[in] p_node Pointer to a cointainer node for this drawer
        */
        void init( Ogre::SceneNode *p_node );

        /**
            @brief Updates the drawer
        */
	    void step();

        /**
            @brief Draws a portal
            @param[in] p_portal Pointer to the portal to be drawn
        */
	    void drawPortal( Ogre::Portal *p_portal );

        /**
            @brief Draws a node bounding box
            @param[in] p_node Pointer to the node
        */
        void drawNode( Ogre::SceneNode *p_node );

        /**
            @brief Enables or disables the drawer
            @param[in] b_on Should the drawer be enabled?
        */
	    void set_enabled( bool b_on );
	
        /**
            @brief Gets drawer enabled state
            @return True if it's enabled, otherwise false
        */
	    inline int get_enabled() const {
		    return m_debug;
	    }

    protected:
        //! Drawer scene node
        Ogre::SceneNode *m_node;
        //! Pointer to the debug line drawer
	    BtOgre::DynamicLines *m_line_drawer;
        //! Is debug mode switched on?
	    bool m_debug;
    };

    //! Drawer global
    extern PORTAL_DRAWER g_portal_drawer;
}
}

#endif //PM3_PORTAL_DEBUG_HPP

